using System.Collections.Generic;
using System.Runtime.Serialization;
using UnityEngine;

namespace GMME
{
    [DataContract]
    public class RemotePlayerPosition
    {
        // 玩家openId 
        [DataMember(Name = "openId")]
        public string OpenId
        {
            get;
            set;
        }

        // 坐标对象
        [DataMember(Name = "position")]
        public PlayerPosition Position
        {
            get;
            set;
        }

#if UNITY_ANDROID
        internal static RemotePlayerPosition ConvertRemotePlayerPosition(AndroidJavaObject javaObject)
        {
            RemotePlayerPosition remotePlayerPosition = new RemotePlayerPosition();
            if (javaObject != null)
            {
                string openId = javaObject.Call<string>("getOpenId");
                remotePlayerPosition.OpenId = openId;
                PlayerPosition position = javaObject.Call<PlayerPosition>("getPlayerPosition");
                remotePlayerPosition.Position = position;
            
                Debug.LogFormat("OpenId={0}, Position={1}", remotePlayerPosition.OpenId, remotePlayerPosition.Position);
            }
            return remotePlayerPosition;
        }
#endif
    }
}
